package edu.predatorwars.shared.models;

import java.awt.Point;

import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;

@JsonIgnoreProperties("targetPoint")
public class Move implements Comparable<Move> 
{
	private final int targetX;
	private final int targetY;
	
	@JsonCreator
	public Move(@JsonProperty("targetX") int x, @JsonProperty("targetY") int y)
	{
		this.targetX = x;
		this.targetY = y;
	}

	public int getTargetX() 
	{
		return targetX;
	}

	public int getTargetY() 
	{
		return targetY;
	}
	
	public Point getTargetPoint()
	{
		return new Point(targetX, targetY);
	}
	
	@Override public String toString() {
		return "Location: " + targetX +", " + targetY;
	}

	@Override public boolean equals(Object obj) {
		if (!(obj instanceof Move)) {
			return false;
		}
		
		Move m = (Move)obj;
		return m.targetX == targetX && m.targetY == targetY;
	}
	
	@Override public int compareTo(Move arg0) {
		if (arg0.targetX > targetX || arg0.targetY > targetY) {
			return -1;
		}
		if (arg0.targetX < targetX || arg0.targetY < targetY) {
			return 1;
		}
		return 0;
	}
}
